home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / comm / misc / mirrorman_1_10b1.lha / MirrorManager-1.10b1 / rexx / Status.mm < prev   
Text File  |  1994-06-24  |  2KB  |  72 lines

  1. /*
  2. **  $VER: $Id: Status.mm,v 1.3 1994/06/20 01:08:34 tf Exp $
  3. */
  4.  
  5. options results
  6. options failat 21
  7.  
  8. /* initialize globals */
  9.  
  10. logfile  = "T:MirrorManagerStatus." || pragma('Id')
  11. tempfile = "T:MirrorManagerStatusTemp." || pragma('Id')
  12. patstr   = "Warning"
  13.  
  14. ESC      = '1b'x
  15.  
  16. /**/
  17.  
  18. WORKING '"Saving..."'
  19. SAVELOG '"'logfile'"'
  20.  
  21. WORKING '"Extracting important lines ..."'
  22. address command 'Search QUICK FROM "'logfile'" PATTERN "'patstr'" NONUM > "'tempfile'"'
  23.  
  24. MESSAGE CLEAR; MESSAGE OPEN
  25. WORKING '"Loading ..."'
  26.  
  27. if loadlog(tempfile) = 0 then do
  28.   REQUESTCHOICE TITLE   '"Status Request"',
  29.                 BODY    '"failed to open my temporaty file*n*n' ||,
  30.                         ESC'c'ESC'b' || tempfile || ESC'n'ESC'l'    || '"',
  31.                 GADGETS '"Hummmm"'
  32.   call loadlog(logfile)
  33.   end
  34.  
  35. if exists(logfile)  then address command 'Delete QUIET FILE "'logfile'"'
  36. if exists(tempfile) then address command 'Delete QUIET FILE "'tempfile'"'
  37.  
  38. WORKING '"done."'
  39. exit 0
  40.  
  41. /*@*/
  42.  
  43. loadlog: procedure
  44.   parse arg fname
  45.   numlines= 0
  46.   if open('fp',fname,'R') then do
  47.     do until eof('fp')
  48.       s= readln('fp')
  49.       if words(s) > 0 then do
  50.         numlines= numlines+1;
  51.         MESSAGE transquote(s)
  52.         end
  53.       end
  54.     call close('fp')
  55.     end
  56.   return numlines
  57.  
  58.  
  59.  
  60. /* translate '"' into '*"' and '*' into '**' */
  61.  
  62. transquote: procedure
  63.   parse arg s
  64.   t= s
  65.   q= max( lastpos('*',s), lastpos('"',s) )
  66.   do while q > 0
  67.     t= insert('*',t,q-1,1)
  68.     s= left(s,q-1)
  69.     q= max( lastpos('*',s), lastpos('"',s) )
  70.     end
  71.   return '"' || t || '"'
  72.